﻿package hapi.web;

class ParamPathMatcher implements PathMatcher {
	
	var param:String;
	public function new(param:String) {
		this.param = param;
	}
	
	public function match(part:String, paramsToFill:{} ):Bool {
		Reflect.setField(paramsToFill, param, part);
		return true;
	}
	
	public function resolve(params:{}):String {
		for (f in Reflect.fields(params)) {
			if ( f == param) {
				return Reflect.field(params, f);
			}
		}
		return "";
	}
	
	public function paramsMatch(params: { } ):Bool {
		return Reflect.hasField( params, param);
	}
}